<?php
header("content-type:text/html; charset=utf-8");
//header("content-type:text/html; charset=gbk");

date_default_timezone_set('PRC');
session_start();

define("MAX_SUPPLY_NUM", 100000000);
define("CONNECTION_KEY", "connection");
define("POST_JSON_PARAM_KEY", "post_json");
define("POST_FILTER_PARAM_KEY", "filter");
define("ROOT_PATH", dirname(__FILE__));
define("APP_PATH", ROOT_PATH);
define("MODELS_PATH", "models");
define("UPLOAD_FILE_ROOT_DIR", "upload");
define("DEF_UPLOAD_FILE_ROOT_DIR", ROOT_PATH.DIRECTORY_SEPARATOR.UPLOAD_FILE_ROOT_DIR.DIRECTORY_SEPARATOR);


define("MANAGE_APIS_ROOT", "manage".DIRECTORY_SEPARATOR."controllers");
define("DB_IMPLEMENTS_CLASS", "DbUtils");
define("DB_IMPLEMENTS_PATH", "Utils");
define("CONTROLLER_PATH_KEY", "ctrlRoot");
define("CONTROLLER_NAME_KEY", "ctrlName");
define("CONTROLLER_FUNC_KEY", "func");


/**************Dept Type*******************/
define("SHOP", 1);     		      //门店
define("PURCHASER", 2); 		  //采购部
define("DC", 3);       		      //配送中心
/**************Stock Type*****************/
define("STOCK_IN", 1); 		      //通用入库单
define("OUT", 2);      		      //通用出库单
define("TRANSFER_IN", 3);         //调拨入库单
define("TRANSFER_OUT", 4);        //调拨出库单
define("SALE", 5);                //销售出库单 
define("SALE_RETURN", 6);         //销售退货单
define("PURCHASE", 7);            //采购单 
define("PURCHASE_RETURN", 8);     //采购退货单
/**************Stock State*****************/
define("STOCK_NEW", 100);         //新建未处理
define("STOCK_PADDING",  110);    //处理中
define("STOCK_REOPENED", 101);    //关闭后重新打开尚未处理
define("STOCK_FINISHED", 200);    //处理完成（已经写入库存表）    
define("STOCK_CANCELED", 300);    //取消

define("CORPID", "wxef301686f5051afb"); //CORPID
define("CORPSECRET", "Mff4umYwoyFdTH57lsMxm2Pye4mLpIbSYC_emAYR6M0X4-JGHRqwTxeDHiYTVa6U"); //CORPSECRET

/****************需要静态包含的文件*****************/

requireOnce("Abstract");
requireOnce("Utils");
requireOnce("common");
require_once("models/Users.php");
require_once ('wechat/CreateConnection.php');
include_once('Excel/Classes/PHPExcel.php');
require_once ('wechat/Tools.php');
require_once ('wechat/CreateConnection.php');
require_once ('wechat/Agent.php');
require_once ('wechat/Chat.php');
require_once ('wechat/Department.php');
require_once ('wechat/Material.php');
require_once ('wechat/Menu.php');
require_once ('wechat/SendMessage.php');
require_once ('wechat/Tag.php');
require_once ('wechat/User.php');
require_once ('wechat/JSSDK.php');
require_once ('wechat/AccessTokenManager.php');

//requireOnce("Excel");
/*require_once ('Abstract/AbstractBean.php');
require_once ('Abstract/Utils.php');

require_once ('Abstract/AbstractController.php');
require_once ('Abstract/AbstractDbUtils.php');
require_once ('Abstract/CustomerException.php');
require_once ('Abstract/Message.php');
require_once ('Util
s/DbUtils.php');
require_once ('Utils/PageUtils.php');
require_once ('Utils/Page.php');
require_once ('Utils/UploadUtil.php');
require_once ('Utils/Logs.php');
require_once ('common/BaseBean.php');
require_once ('common/BaseController.php');
require_once ('models/Users.php');
require_once ('models/Shop.php');
require_once ('models/Stock.php');
require_once ('wechat/Tools.php');
require_once ('wechat/CreateConnection.php');
require_once ('wechat/Agent.php');
require_once ('wechat/Chat.php');
require_once ('wechat/Department.php');
require_once ('wechat/Material.php');
require_once ('wechat/Menu.php');
require_once ('wechat/SendMessage.php');
require_once ('wechat/Tag.php');
require_once ('wechat/User.php');
require_once ('wechat/JSSDK.php');*/




 function requireOnce($directory,$pattern = "php"){
    $mydir = dir(APP_PATH.DIRECTORY_SEPARATOR.$directory); 
    while($fileName = $mydir->read()){ 
        if((is_dir($directory.DIRECTORY_SEPARATOR.$fileName)) && ($fileName!=".") && ($fileName!="..")) {
            requireOnce($directory.DIRECTORY_SEPARATOR.$fileName,$pattern); 
        } 
        else if (($fileName!=".") && ($fileName!="..") ){
        	$arr = explode(".",$fileName);
        	if($arr[1]!=$pattern && $pattern !="*"){
        		continue;
        	}
        	$filePath = APP_PATH.DIRECTORY_SEPARATOR.$directory.DIRECTORY_SEPARATOR.$fileName;
        	if (is_readable($filePath)) {
	       		require_once $filePath; 
		    }
        }
    } 
    $mydir->close(); 
 }



//set_exception_handler(CustomerException::customer_exception_handler);







?>